home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1362 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  59 lines

  1. Path: news.cuny.edu!apccu
  2. From: Paul Abrilla <APCCU@CUNYVM.CUNY.EDU>
  3. Newsgroups: comp.lang.c++
  4. Subject: Help on C++ error
  5. Date: Wed, 10 Jan 1996 11:25:07 EST
  6. Organization: City University of New York/University Computer Center
  7. Message-ID: <96010.112507APCCU@CUNYVM.CUNY.EDU>
  8. NNTP-Posting-Host: cunyvm.cuny.edu
  9. Disclaimer: Author bears full responsibility for this post
  10.  
  11. Hi to all,
  12.  
  13. I'm just starting to code on C++, and was playing around with classes and
  14. came across an error and a warning when I try to compile the code below.
  15. The warning is complaining about the statement, 'int Cat::SetAge(age)'.
  16. It says, 'Style of function definition is now obsolete'.  I'm sorry I couldn't
  17. check my compiler's manual at this time.  On the other hand, the error says,
  18. 'Cat::SetAge(int)' is not a member of 'Cat' (line:19).  Any help will be
  19. appreciated.  Please send replies directly tp my account.  Thanks in advance.
  20.  
  21. By the way, I'm using Turbo C++ for windows 3.1 by Borland. Thanks again../Paul
  22.  
  23. #include <iostream.h>
  24.  
  25. class Cat
  26. {
  27.   public:
  28.     int GetAge();
  29.     void SetAge (int age);
  30.     void Meow();
  31.   private:
  32.     int itsAge;
  33. };
  34.  
  35. int Cat::GetAge()
  36. {
  37.   return itsAge;
  38. }
  39.  
  40. int Cat::SetAge(age)
  41. {
  42.   itsAge = age;
  43. }
  44.  
  45. void Cat::Meow()
  46. {
  47.   cout << "Meow..meow...\n";
  48. }
  49. void main()
  50. {
  51.   Cat Frisky;
  52.   Frisky.SetAge(5);
  53.   Frisky.Meow();
  54.   cout << "Frisky is a cat who is ";
  55.   cout << Frisky.GetAge() << " years old.\n";
  56.   Frisky.Meow();
  57. }
  58.  
  59.